package day06_exception_collection.com.itheima.d3_collection_api;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

public class CollectionAPTDemo1 {
    public static void main(String[] args) {
        Collection<String> list = new ArrayList<String>();
        list.add("hello");
        list.add("world");
        list.add("java");
        list.add("张三");
        System.out.println(list);
//
//        list.clear();
//        System.out.println("list = " + list);

        System.out.println("list.isEmpty() = " + list.isEmpty());

        System.out.println("list.remove(\"hello\") = " + list.remove("hello"));
        System.out.println("list = " + list);

        System.out.println("list.contains(\"hello\") = " + list.contains("hello"));

        System.out.println("list.size() = " + list.size());

        Object[] array = list.toArray();
        System.out.println("Arrays.toString(array) = " + Arrays.toString(array));

        String[] arrays = list.toArray(String[]::new);
        System.out.println("arrays = " + arrays);

        Collection<String> c1 = new ArrayList<>();
        c1.add("hello");
        c1.add("world");

        Collection<String> c2 = new ArrayList<>();
        c2.add("java");
        c2.add("world");
        c2.addAll(c1);
        System.out.println("c1 = " + c1);
        System.out.println("c2 = " + c2);
    }
}
